$(function () {
    var windowH = $(window).height();
    var windowW = $(window).width();
    if ($('div').hasClass('pageWrapper')) {
        $(document).on('click', '.menu_top', function () {
            $(".pageWrapper").mCustomScrollbar("scrollTo", 'top');
        });
        var aa = $(".innerContent");
        aa.css({
            "-webkit-transform": "none",
            "-moz-transform": "none",
            "-ms-transform": "none",
            "-o-transform": "none",
            transform: "none"
        })
        $(".pageWrapper").mCustomScrollbar({
            theme: "minimal-dark",
            scrollInertia: 750,
            mouseWheel: {
                scrollAmount: 300
            },
            callbacks: {
                whileScrolling: function () {
                    if (this.mcs.top == 0) {
                        $('.header').removeClass('scrollHeader');
                    } else {
                        $('.header').addClass('scrollHeader');
                    }
                    myCallback(this);
                }
            },
            advanced: {
                autoUpdateTimeout: 1,
                updateOnContentResize: !0
            }
        });
        (function () {
            var a, b = [], c = [], d = [], e = 0, f = [];
            a = $(".innerContent").find(".case_fixed_img"),
                contentOffset = $(".innerContent").offset().top;
            var g = a.length, h = 0, i = 0, j = [], k = [], l = [], m = [];
            b[0] = $(a[0]).outerHeight();
            c[0] = $(a[0]).offset().top - contentOffset;
            d[0] = c[0] + b[0];
            j[0] = 0;
            k[0] = 100 / b[0];
            var e = $(window).height();
            f[0] = e - c[0];
            l[0] = f[0] * k[0];
            m[0] = j[0] + l[0];

            if (e > c[0] && e < d[0]) {
                $(a[0]).find(".before").css({
                    "-webkit-transform": "translateX(-" + m[0] + "%)",
                    "-moz-transform": "translateX(-" + m[0] + "%)",
                    "-ms-transform": "translateX(-" + m[0] + "%)",
                    "-o-transform": "translateX(-" + m[0] + "%)",
                    transform: "translateX(-" + m[0] + "%)"
                });
                $(a[0]).find(".after").css({
                    "-webkit-transform": "translateX(" + m[0] + "%)",
                    "-moz-transform": "translateX(" + m[0] + "%)",
                    "-ms-transform": "translateX(" + m[0] + "%)",
                    "-o-transform": "translateX(" + m[0] + "%)",
                    transform: "translateX(" + m[0] + "%)"
                })
            } else if (e <= c[0]) {
                $(a[0]).find(".before").css({
                    "-webkit-transform": "translateX(0%)",
                    "-moz-transform": "translateX(0%)",
                    "-ms-transform": "translateX(0%)",
                    "-o-transform": "translateX(0%)",
                    transform: "translateX(0%)"
                });
                $(a[0]).find(".after").css({
                    "-webkit-transform": "translateX(0%)",
                    "-moz-transform": "translateX(0%)",
                    "-ms-transform": "translateX(0%)",
                    "-o-transform": "translateX(0%)",
                    transform: "translateX(0%)"
                })
            } else if (e >= d[0]) {
                $(a[0]).find(".before").css({
                    "-webkit-transform": "translateX(-100%)",
                    "-moz-transform": "translateX(-100%)",
                    "-ms-transform": "translateX(-100%)",
                    "-o-transform": "translateX(-100%)",
                    transform: "translateX(-100%)"
                });
                $(a[0]).find(".after").css({
                    "-webkit-transform": "translateX(100%)",
                    "-moz-transform": "translateX(100%)",
                    "-ms-transform": "translateX(100%)",
                    "-o-transform": "translateX(100%)",
                    transform: "translateX(100%)"
                })
            }
        })();
        function myCallback(el) {
            var a, b = [], c = [], d = [], e = 0, f = [];
            a = $(".innerContent").find(".case_fixed_img"),
                contentOffset = $(".innerContent").offset().top;
            var g = a.length, h = 0, i = 0, j = [], k = [], l = [], m = [];
            for (h = 0; h < g; h += 1) {
                if (h === g - 1) {
                    b[h] = $(a[h]).outerHeight() - 200;
                } else {
                    b[h] = $(a[h]).outerHeight();
                }
                c[h] = $(a[h]).offset().top - contentOffset;
                d[h] = c[h] + b[h];
                j[h] = 0;
                k[h] = 100 / b[h];
            }
            var e = -1 * el.mcs.top + $(window).height();

            for (h = 0; h < g; h += 1) {
                f[h] = e - c[h];
                l[h] = f[h] * k[h];
                m[h] = j[h] + l[h];
                if (e > c[h] && e < d[h]) {
                    $(a[h]).find(".before").css({
                        "-webkit-transform": "translateX(-" + m[h] + "%)",
                        "-moz-transform": "translateX(-" + m[h] + "%)",
                        "-ms-transform": "translateX(-" + m[h] + "%)",
                        "-o-transform": "translateX(-" + m[h] + "%)",
                        transform: "translateX(-" + m[h] + "%)"
                    });
                    $(a[h]).find(".after").css({
                        "-webkit-transform": "translateX(" + m[h] + "%)",
                        "-moz-transform": "translateX(" + m[h] + "%)",
                        "-ms-transform": "translateX(" + m[h] + "%)",
                        "-o-transform": "translateX(" + m[h] + "%)",
                        transform: "translateX(" + m[h] + "%)"
                    })
                } else if (e <= c[h]) {
                    $(a[h]).find(".before").css({
                        "-webkit-transform": "translateX(0%)",
                        "-moz-transform": "translateX(0%)",
                        "-ms-transform": "translateX(0%)",
                        "-o-transform": "translateX(0%)",
                        transform: "translateX(0%)"
                    });
                    $(a[h]).find(".after").css({
                        "-webkit-transform": "translateX(0%)",
                        "-moz-transform": "translateX(0%)",
                        "-ms-transform": "translateX(0%)",
                        "-o-transform": "translateX(0%)",
                        transform: "translateX(0%)"
                    })
                } else if (e >= d[h]) {
                    $(a[h]).find(".before").css({
                        "-webkit-transform": "translateX(-100%)",
                        "-moz-transform": "translateX(-100%)",
                        "-ms-transform": "translateX(-100%)",
                        "-o-transform": "translateX(-100%)",
                        transform: "translateX(-100%)"
                    });
                    $(a[h]).find(".after").css({
                        "-webkit-transform": "translateX(100%)",
                        "-moz-transform": "translateX(100%)",
                        "-ms-transform": "translateX(100%)",
                        "-o-transform": "translateX(100%)",
                        transform: "translateX(100%)"
                    })
                }
            }
        }
    }
})
